package com.smcdd.cdb.dbo.cdb_dbo.ui.utils;

import android.util.Log;

import com.smcdd.cdb.dbo.cdb_dbo.app.App;
import com.smcdd.cdb.dbo.cdb_dbo.service.entity.Statistics;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 作者：Administrator on 2017/6/8 17:20
 * 邮箱：zhanghuaiha@gmail.com
 *
 * 获取encry参数
 */

public class ObtainEncry {
    private static String MD5 = "7q238*whowi*&dkfSKDWIE812*(23z7^&*12ksjSKW7";

    public static String getEncry(Map<String, String> map){
        StringBuffer stringBuffer = new StringBuffer();
        Iterator<Map.Entry<String, String>> iterator= map.entrySet().iterator();
        int i = 0;
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            if (i == 0) {
                stringBuffer.append(next.getKey() + "=" + next.getValue());
            }else {
                stringBuffer.append("&"+next.getKey() + "=" + next.getValue());
            }
            i++;
        }
        String encry = stringBuffer.toString()+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }


    /**
     * 获取新版本
     */
    public static String getVersion(String rf, String ts, String v, String i,String udid){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }


    /**
     * 获取验证码
     */
    public static String getCode(String rf, String ts, String v, String i,String udid,String mobile){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&mobile="+mobile+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 登录
     */
    public static String login(String rf, String ts, String v, String i,String udid,String mobile,String code,String device_type,String brand,String model,String version_sdk,String version_release,String software_version){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&mobile="+mobile+"&code="+code+"&device_type="+device_type+"&brand="+brand+"&model="+model+"&version_sdk="+version_sdk+"&version_release="+version_release+"&software_version="+software_version+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 9宫格
     */
    public static String getFunctions(String rf, String ts, String v, String i,String udid,String eid){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 扫一扫解析
     */
    public static String getParse(String rf, String ts, String v, String i,String udid,String eid,String qrcode){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&qrcode="+qrcode+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 扫一扫解析
     */
    public static String getStart2charging(String rf, String ts, String v, String i,String udid,String alias,String eid){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&alias="+alias+"&eid="+eid+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 查询设备固件版本
     */
    public static String getQuery(String rf, String ts, String v, String i,String udid,String eid,String alias){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&alias="+alias+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }


    /**
     * 设备故障
     */
    public static String getHardware(String rf, String ts, String v, String i,String udid,String alias,String eid,String content){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&alias="+alias+"&eid="+eid+"&content="+content+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 获取商铺信息
     */
    public static String getStoreInfog(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String status){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&status="+status+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 所属设备
     */
    public static String getCharging2Page(String rf, String ts, String v, String i, String udid,String id, String eid, String page_size,String page_index){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&id="+id+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 删除
     */
    public static String Delete(String rf, String ts, String v, String i, String udid,String id, String eid){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&id="+id+"&eid="+eid+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 获取商铺信息
     */
    public static String getStoreInfo(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 激活设备
     */
    public static String getActivation(String rf, String ts, String v, String i, String udid, String eid, String alias,String name,String remark,String store_info_id){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&alias="+alias+"&name="+name+"&remark="+remark+"&store_info_id="+store_info_id+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 上传图片
     */
    public static String uploadImage(String i, String rf, String ts, String udid,String v){
//        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+MD5;
        String encry = "i="+i+"&rf="+rf+"&ts="+ts+"&udid="+udid+"&v="+v+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 新增店铺
     */
    public static String insert(String rf, String ts, String v, String i, String udid, String eid, String name,String contact,String tel,String latitude,String longitude,String province_id,String city_id,String area_id,String specific_address,String province_name,String city_name,String area_name,String position,String position_name,String img_url,String from_type,String remark){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&name="+name+"&contact="+contact+"&tel="+tel+"&latitude="+latitude+"&longitude="+longitude+"&province_id="+province_id+"&city_id="+city_id+"&area_id="+area_id+"&specific_address="+specific_address+"&province_name="+province_name+"&city_name="+city_name+"&area_name="+area_name+"&position="+position+"&position_name="+position_name+"&img_url="+img_url+"&from_type="+from_type+"&remark="+remark+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 更新店铺
     */
    public static String update(String rf, String ts, String v, String i, String udid,String id, String eid, String name,String contact,String tel,String latitude,String longitude,String province_id,String city_id,String area_id,String specific_address,String province_name,String city_name,String area_name,String position,String position_name,String img_url,String from_type,String remark){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&id="+id+"&eid="+eid+"&name="+name+"&contact="+contact+"&tel="+tel+"&latitude="+latitude+"&longitude="+longitude+"&province_id="+province_id+"&city_id="+city_id+"&area_id="+area_id+"&specific_address="+specific_address+"&province_name="+province_name+"&city_name="+city_name+"&area_name="+area_name+"&position="+position+"&position_name="+position_name+"&img_url="+img_url+"&from_type="+from_type+"&remark="+remark+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }


    /**
     * 获取商铺信息
     */
    public static String getStatistics(String rf, String ts, String v, String i, String udid, String eid){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 获取商铺信息
     */
    public static String getMessage(String rf, String ts, String v, String i, String udid, String message_id){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&message_id="+message_id+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * //统计报表
     */
    public static String getStatistics_store(String rf, String ts, String v, String i, String udid,String eid, String sid,String start_date,String end_date){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&sid="+sid+"&start_date="+start_date+"&end_date="+end_date+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 获取当前设备的详情
     */
    public static String getCdb_info(String rf, String ts, String v, String i, String udid,String eid, String alias){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&alias="+alias+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 改变灯光状态
     */
    public static String getState(String rf, String ts, String v, String i, String udid,String alias, String eid,String status){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&alias="+alias+"&eid="+eid+"&status="+status+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 个人历史
     */
    public static String getMe_History(String rf, String ts, String v, String i, String udid,String eid,String start_date,String end_date){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&start_date="+start_date+"&end_date="+end_date+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 统计页面
     */
    public static String getAll_info(String rf, String ts, String v, String i, String udid,String eid,String date){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&date="+date+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 统计页面
     */
    public static String getDay_shop(String rf, String ts, String v, String i, String udid,String eid,String page_size,String page_index){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 已安装设备分页根据电量
     */
    public static String getPage(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String electricity_sc_status){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&electricity_sc_status="+electricity_sc_status+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 已安装设备分页根据电量百分比
     */
    public static String getPageBfb(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String dump_energy_per){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&dump_energy_per="+dump_energy_per+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     //已安装设备分页根据在线离线排序
     */
    public static String getPage_on2off_line(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String on_line){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&on_line="+on_line+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 已安装设备分页根据电量+在线
     */
    public static String getPage_on2off_line_sort(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String electricity_sc_status,String on_line){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&electricity_sc_status="+electricity_sc_status+"&on_line="+on_line+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 已安装设备分页根据电量+在线+百分比
     */
    public static String getPage_on2off_bfb_sort(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String dump_energy_per,String on_line){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&dump_energy_per="+dump_energy_per+"&on_line="+on_line+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 已安装设备分页根据电量+在线
     */
    public static String getPage_on2off_line_day(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String on_line,String offline_day){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&on_line="+on_line+"&offline_day="+offline_day+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }


    /**
     * 已安装设备分页根据电量+在线
     */
    public static String getPage_off_line_day(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String on_line,String electricity_sc_status,String offline_day){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&on_line="+on_line+"&electricity_sc_status="+electricity_sc_status+"&offline_day="+offline_day+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }

    /**
     * 已安装设备分页根据电量+在线+百分比
     */
    public static String getPage_off_bfb_day(String rf, String ts, String v, String i, String udid, String eid, String page_size,String page_index,String on_line,String dump_energy_per,String offline_day){
        String encry = "rf="+rf+"&ts="+ts+"&v="+v+"&i="+i+"&udid="+udid+"&eid="+eid+"&page_size="+page_size+"&page_index="+page_index+"&on_line="+on_line+"&dump_energy_per="+dump_energy_per+"&offline_day="+offline_day+MD5;
        Log.e("encry",encry);
        String md = Md5Utils.md5(encry);
        Log.e("md",md);
        return md;
    }



}
